package com.visionarysoftwaresolutions

import grails.test.mixin.*
import org.junit.*

/**
 * See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage instructions
 */
@TestFor(Picture)
class PictureTests {

    void testInvalidPictureTooBig() {
       def max = 1024*1024*1024*1+50 
       byte[] data = new byte[max]
       def pic = new Picture(image:data)
       mockForConstraintsTests(Picture, [pic])
       assert !pic.validate()
       assert "maxSize" == pic.errors["image"]
    }
    
    void testValidPicture(){
       byte[] data = new byte[5]
       def pic = new Picture(image:data)
       mockForConstraintsTests(Picture, [pic])
       assert pic.validate() 
    }
}
